<?php
namespace app\admin\model;

use think\Model;

class Store extends Model
{
	protected $name = 'store';
    protected $type = [
        'add_time' => 'timestamp:Y-m-d H:i:s',
        'upd_time' => 'timestamp:Y-m-d H:i:s',
        'approve_time' => 'timestamp:Y-m-d H:i:s',
    ];

    // 定义时间戳字段名
    protected $addTime = 'create_at';
    protected $updTime = 'update_at';

    protected function getAddTimeAttr($value)
    {
        if(!empty($value)) return '';
    }

    protected function getUpdTimeAttr($value)
    {
        if(!empty($value)) return '';
    }

    protected function getApproveTimeAttr($value)
    {
        if(!empty($value)) return '';
    }
    /**
     * 订单类修改器 含防重复筛查
     * Power by Mikkle
     * QQ:776329498
     * @param $value
     * @param $data
     * @return string
     */
    protected function setStoreNoAttr($value, $data)
    {
        do {
            $store_no= get_store_no();
        } while ($this->where('store_no',$store_no)->count()==1);
        return $store_no;
    }

    public function stores(){
        return $this->hasOne('Image', 'image');
    }
}